/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.util.ArrayList;
import pojo.Hinhanh;
import until.MySqlDataAccessHelper;

/**
 *
 * @author Administrator
 */
public class HinhAnh_DAO {
        public static ArrayList<Hinhanh> layHinhAnhTheoMaDeal(int maDeal) {
        ArrayList<Hinhanh>ds= new ArrayList<Hinhanh>();
        String sql = String.format("select * from hinhanh where MaDeal="+maDeal+"");
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql);
        try {
            while (rs.next()) {
                Hinhanh ha= new Hinhanh();
                ha.setId(rs.getInt("ID"));
                ha.setMaDeal(rs.getInt("MaDeal"));
                ha.setUrl(rs.getString("URL"));
                ha.setKieuHinh(rs.getString("KieuHinh"));
                ds.add(ha);
            }
        } catch (Exception e) {
            System.out.print(e.getMessage());
        }
        return ds;
    }
    
}
